/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.network;
import com.cse.p2p.common.CommonSettings;
import java.io.*;
import java.net.*;
import com.cse.p2p.common.*;
import com.cse.p2p.database.*;
import com.cse.p2p.hash.*;
import com.cse.p2p.localfile.*;
import com.cse.p2p.parser.*;
/**
 *
 * @author TuyetNgan
 */
public class ClientControlTask_Client  extends Thread {
    private  String machine;
	private  int portControl;
	private  Socket clientSocket = null;

	private  BufferedReader infromScreen = null;
	private  BufferedReader in = null;
	private  PrintStream out = null;
    private  String IPconnect;

    
    public ClientControlTask_Client( String ip, int p){
        this.IPconnect = ip;
        this.portControl = p;
    }
	public void  newChat(){
		try{
            clientSocket = new Socket(IPconnect,portControl);
			out = new PrintStream(new DataOutputStream(clientSocket.getOutputStream()));
		 	in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
        infromScreen = new BufferedReader(new InputStreamReader(System.in));
		}
		catch(IOException e){}
	}
    public void closeConnection(){
			try {
				out.close();
				in.close();
				clientSocket.close();
			}
			catch (IOException e){}

	}

    
	public void run() {
       
         newChat();
         closeConnection();

    }    
}
